import numpy as np
import cv2
from matplotlib import pyplot as plt


img = cv2.imread('pic2.jpg')
rows,cols,ch = img.shape
pts1 = np.float32([[20,20],[110,20],[50,110]])
pts2 = np.float32([[10,50],[120,40],[30,150]])
M = cv2.getAffineTransform(pts1,pts2)
dst = cv2.warpAffine(img,M,(cols,rows))
plt.subplot(121),plt.imshow(img),plt.title('Input')
plt.subplot(122),plt.imshow(dst),plt.title('Output')
plt.show()
